package com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;


import java.util.List;

/**
 * Created by Administrator on 2018/8/10.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class DownloListViewPagerAdapter extends FragmentStatePagerAdapter {
    private String[] titles = { "下载列表", "下载完成"};
    private  List<Fragment> mlist;
    private Context context;

    public DownloListViewPagerAdapter(FragmentManager childFragmentManager, Context mContext, List<Fragment> list) {
        super(childFragmentManager);
        mlist=list;
        context = mContext;
    }


    @Override
    public Fragment getItem(int position) {
        return mlist.get(position);
    }

    @Override
    public int getCount() {
        return mlist == null ?0:mlist.size();
    }


    /**
     * 自定义方法，提供自定义Tab
     *
     * @param position 位置
     * @return 返回Tab的View
     */
    public View getTabView(int position, TabLayout tab) {
        View v = LayoutInflater.from(context).inflate(R.layout.download_tab_custom, null);
        TextView textView = (TextView) v.findViewById(R.id.download_tab_custom_tv_title);
        textView.setText(titles[position]);
        //添加一行，设置颜色
        textView.setTextColor(tab.getTabTextColors());//
        return v;
    }
}
